package com.xb.loan.util;

import java.util.regex.Pattern;

public class RegValideUtil {

    /**
     *正则验证
     * @return
     */
    public static boolean regValide(String regex,String content){
        return Pattern.matches(regex, content);
    }
    
    /**
     *手机号验证
     * @return
     */
    public static boolean phoneValide(String phone){
        return regValide("^1[3|4|5|8][0-9]\\d{8}$", phone);
    }
    
    /**
     *数字验证
     * @return
     */
    public static boolean numberValide(String number){
        return regValide("^[0-9]*$", number);
    }
    
    /**
     *金额验证
     * @return
     */
    public static boolean moneyValide(String money){
        return regValide("^(([1-9]\\d{0,9})|0)(\\.\\d{1,2})?$", money);
    }
    
    /**
     *中文验证
     * @return
     */
    public static boolean cnValide(String cn){
        return regValide("[\\u4e00-\\u9fa5]+", cn);
    }
    
    public static void main(String[] args) {
//        System.out.println(phoneValide("1591073251"));
//        System.out.println(numberValide(""));
        System.out.println(moneyValide("0.00"));
//        System.out.println(cnValide("中国"));
    }
}
